package app.netant.badbook.luoqiu;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class LuoQiuDetail extends BaseDetail {

	public LuoQiuDetail(String netSite) {
		super(netSite);
		this.preHref = "http://www.luoqiu.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".main #centerm #content .sf-mainbox .head h1 a");
		if(parts.size()>1){
			String title = parts.get(1).text();
			System.out.println("【Title】："+title);
		}
	}

	@Override
	public void analyseTags() {
		Elements parts = this.select(".main #centerm #content .sf-mainbox .body table.box tbody tr td "
				                   + "table[cellpadding='3'][cellspacing='2'] tbody tr td[nowrap='nowrap'] "
				                   + "table tbody tr td[width='79%'] "
				                   + "table tbody tr td[align='center']");
		for(int i=0;i<parts.size();i++){
			System.out.println(i+"="+this.getString(parts.get(i).text()));
		}
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".main #centerm #content .sf-mainbox .body table.box tbody tr td "
                					+ "table[cellpadding='3'][cellspacing='2'] tbody tr td #CrbsSum");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			System.out.println("【Memo】:"+memo);
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".main #centerm #content .sf-mainbox .body table.box tbody tr td "
					                + "table[cellpadding='3'][cellspacing='2'] tbody tr td[nowrap='nowrap'] "
					                + "table tbody tr td[width='79%'] "
					                + "table tbody tr td[colspan='6'] div a");
		for(int i=0;i<parts.size();i++){
			String href = parts.get(i).attr("href");
			if(href.startsWith("/download")){
				href = this.preHref + href;
				System.out.println("【Href】:"+href);
				break;
			}
		}
	}
	
	@Override
	public void analyseType() {
		
	}
	
	public static void main(String[] args) {
		LuoQiuDetail detail = new LuoQiuDetail("http://www.luoqiu.com/book/316742.html");
		System.out.println("解析地址成功............");
		detail.test();
	}



}
